<template>
	<view>
		<view class="popup-mask" v-if="showPopup" @click="hidePopup"></view>
		<view class="popup-wrap" v-if="showPopup">
			<view class="uni-input-wrapper">
				<input class="uni-input customer-input" :placeholder="placeholderTxt" v-model="inputValue" />
			</view>
			<view class="popup-btns">
				<view class="popup-btn" @click="hidePopup">取消</view>
				<view class="popup-btn txt-color-yellow" @click="confirm">确认</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		name: "oneInput",
		props: {
			showPopup: {
				type: Boolean,
				default: false
			},
			placeholderTxt: {
				type: String,
				default: '',
				require: false
			}
		},
		data() {
			return {
				inputValue: "",
				showClearIcon: false,
			};
		},
		methods: {
			confirm() {
				// 点击确认按钮后的操作
				console.log("确认输入的内容为：" + this.inputValue);
				if (!this.inputValue) {
					// 封装的消息提示的方法
					uni.showToast({
						title: '请输入内容',
						duration: 1000,
						icon: 'error',
						position: ''
					})
					return;
				}
				this.$emit('confirmResult', this.inputValue)
				this.inputValue = ''
			},
			hidePopup() {
				// 关闭弹窗
				this.inputValue = ''
				this.$emit('hideDialog')
			},
		}
	};
</script>

<style lang="scss" scoped>
	.uni-input-placeholder {
		color: rgb(192, 196, 204);
		font-size: 30rpx;
	}
	
	
	.popup-mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 999;
	}
	.customer-input {
		border-bottom: 1rpx solid rgb(192, 196, 204);;
		height: 95rpx;
	}

	.popup-wrap {
		position: fixed;
		top: 50%;
		left: 50%;
		width: 80%;
		transform: translate(-50%, -50%);
		background-color: #fff;
		border-radius: 10px;
		padding: 20px;
		z-index: 1000;
	}

	.popup-btns {
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
		color: rgb(96, 98, 102);
		min-height: 60rpx;
	}

	.popup-btn {
		width: 45%;
		height: 40rpx;
		line-height: 100rpx;
		text-align: center;
		border-radius: 5rpx;
		cursor: pointer;
	}

	.btn-wrap {
		position: fixed;
		bottom: 50px;
		left: 50%;
		transform: translateX(-50%);
		z-index: 999;
	}

	.btn {
		width: 100px;
		height: 40px;
		line-height: 40px;
		text-align: center;
		border-radius: 20px;
		background-color: #00a0e9;
		color: #fff;
		cursor: pointer;
	}
</style>
